package com.example.cato_api.controller;

import com.example.cato_entity.entity.Taco;
import org.springframework.hateoas.server.mvc.RepresentationModelAssemblerSupport;

/*
   资源装配器，遍历的作用
 */
public class TacoEntityModelAssembler extends RepresentationModelAssemblerSupport<Taco, TacoEntityModel> {

    public TacoEntityModelAssembler() {
        super(DesignTacoController.class, TacoEntityModel.class);
    }

    @Override // 不仅创建一个对象还要填充链接，在内部toModel会调用instantiateModel
    public TacoEntityModel toModel(Taco entity) {
        return createModelWithId(entity.getId(), entity);
    }

    @Override // 实例化一个Entity对象
    protected TacoEntityModel instantiateModel(Taco entity) {
        return new TacoEntityModel(entity);
    }
}
